package com.liao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liao.bean.Money;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.dao.MoneyDao;
import com.liao.service.MoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MoneyServiceImpl implements MoneyService {

    @Autowired
    private MoneyDao moneyDao;

    @Override
    public PageResult<Money> queryMoneyListByPage(Integer currentPage, Integer pageSize, String userId) throws Exception {
        PageHelper.startPage(currentPage,pageSize);
        //查询所有菜单
        List<Money> moneyList = moneyDao.selectMoneyListLikeMoneyName(userId);
        PageInfo<Money> pageInfo = new PageInfo<>(moneyList);
        return new PageResult<>(0, Msg.MEMBER_QUERY_SUCCESS,pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void addMoney(Money money) throws Exception {
        moneyDao.addMoney(money);
    }

    @Override
    public void editMoney(Money money) throws Exception {
        moneyDao.updateMoney(money);
    }

    @Override
    public void deleteMoney(String umId) throws Exception {
        moneyDao.deleteMoney(umId);
    }

}
